﻿using CinemaMaestro.DataLayer.Contracts.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CinemaMaestro.WebApplication.Models
{
    public class ReservationViewModels
    {
        public int Id { get; set; }
        public int TicketNr { get; set; }
        public int DiscountTicketNr { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string TelephoneNr { get; set; }
        public string Seats { get; set; }

        public virtual ScreeningViewModels Screening { get; set; }

        public static implicit operator ReservationViewModels(Reservation reservation)
        {
            return new ReservationViewModels
            {
                Id = reservation.Id,
                TicketNr = reservation.TicketNr,
                DiscountTicketNr = reservation.DiscountTicketNr,
                Name = reservation.Name,
                Email = reservation.Email,
                TelephoneNr = reservation.TelephoneNr,
                Screening = reservation.Screening,
                Seats = reservation.ReservatedSeats
            };
        }

        public static implicit operator Reservation(ReservationViewModels reservationVM)
        {
            return new Reservation
            {
                Id = reservationVM.Id,
                TicketNr = reservationVM.TicketNr,
                DiscountTicketNr = reservationVM.DiscountTicketNr,
                Name = reservationVM.Name,
                Email = reservationVM.Email,
                TelephoneNr = reservationVM.TelephoneNr,
                Screening = reservationVM.Screening,
                ReservatedSeats = reservationVM.Seats
            };
        }

        public override string ToString()
        {
            return Name;
        }
    }
}